﻿using Microsoft.AspNetCore.Http;

namespace BaseData.Infrastructure.JWT
{
    public class IdentityService : IIdentityService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;

        public IdentityService(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
            this.UserId = _httpContextAccessor.HttpContext?.User.FindFirst("UserId")?.Value;
            this.UserName = _httpContextAccessor.HttpContext?.User.FindFirst("UserName")?.Value;
        }

        public string UserId { get; set; }
        public string UserName { get; set; }
    }
    public interface IIdentityService
    {
        public string UserId { get; set; }
        public string UserName { get; set; }
    }
}
